﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <title>考勤签到</title>
  <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="/JqueryPlug/zTree_v3/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" />
    <link href="/CSS/font-awesome-4.3.0/css/font-awesome.css?v=4.3.0" rel="stylesheet">
    <link href="/CSS/V3/animate.css" rel="stylesheet"> 
    <link href="/CSS/V3/style.css?v=2.2.0" rel="stylesheet">
    <link href="/CSS/V3/BaseClassV3.css" rel="stylesheet" />
    <script src="/Scripts/jquery-1.11.2.min.js"></script> 
    <script src="/JqueryPlug/laypage/laypage.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/SZHLCommon.js?jsver=5"></script>
    <script src="/CSS/V3/jquery-ui.custom.min.js"></script>
    <link href="/CSS/V3/fullcalendar/fullcalendar.css" rel="stylesheet" />
    <link href="/CSS/V3/fullcalendar/fullcalendar.print.css" rel="stylesheet" />
    <script src="/CSS/V3/fullcalendar/fullcalendar.min.js"></script>
    <script src="/JqueryPlug/zTree_v3/js/jquery.ztree.core-3.5.js"></script>
    <script src="/JqueryPlug/zTree_v3/js/jquery.ztree.excheck-3.5.min.js"></script>

    <script>
        var zNodes = null;
        var zTreeObj = null;
        var model = avalon.define({
            $id: "TXSX",
            queryuser: ComFunJS.getnowuser(),
            username: ComFunJS.getnowuser(), 
            Content: "",
            CommonData: [],
            menutype:"-1",
            ShowType:"2",
            AddTXSX: function () {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=TXSX&r=" + Math.random(), "添加数据", "1000", "");
            }, 
            fnqueryuser: function (item) {
                if (item) {
                    model.queryuser = item;
                    model.CommonData.clear(); 
                    model.GetTXData();
                }
            },
            setshowtype: function (t) {
                $(".stbtn button").removeClass("btn-primary").addClass("btn-default");
                $(this).removeClass("btn-default").addClass("btn-primary");

                model.ShowType = t;
                model.GetTXData();
            },
            GetTXData: function () {
                if (model.ShowType == "1") {
                    

                    $.getJSON('/API/FTAPI.ashx?Action=GETCQQDLIST', { p: 1, "QUSER": model.queryuser, b: model.menutype }, function (resultData) {
                        if (resultData.ErrorMsg == "") {
                            model.CommonData.clear();
                            model.CommonData = resultData.Result;
                            if (parseInt(resultData.Result1) > 0) {
                                $("#pageDiv").show();
                                laypage({
                                    cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                                    pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / 8), //通过后台拿到的总页数
                                    curr: 1, //初始化当前页
                                    jump: function (e) { //触发分页后的回调
                                        //if (model.selType != model.Type || model.selContent != model.Content) {
                                        //    e.curr = 1;
                                        //}
                                        $.getJSON('/API/FTAPI.ashx?Action=GETCQQDLIST', { p: e.curr, "QUSER": model.queryuser, b: model.menutype }, function (resultData) {
                                            model.CommonData.clear();
                                            model.CommonData = resultData.Result;
                                        })
                                    }
                                });
                            }
                            else {
                                $("#pageDiv").hide();
                            }
                        }
                    })
                } else if(model.ShowType=="2") {
                    $('#calendar').html("");
                    $('#calendar').fullCalendar({
                        header: {
                            left: 'prev,next today',
                            center: 'title',
                            right: 'month'
                        },
                        monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
                        firstDay:"1",
                        events: function (start, end, callback) {
                            var st = $.fullCalendar.formatDate(start, "yyyy-MM-dd");
                            var ed = $.fullCalendar.formatDate(end, "yyyy-MM-dd");

                            $.getJSON("/API/FTAPI.ashx?action=GETCQQDLIST_BY", { "start": st, "end": ed, P1: model.Type, "QUSER": "'" + model.queryuser + "'" }, function (r) {
                                if (r.Result.length > 0) {
                                    callback(r.Result);
                                }
                            })
                        }
                    });

                }
            },
            EditTXSX: function (Id) {

                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=TXSX&ID=" + Id+"&r=" + Math.random(), "添加数据", "1000", "");
            },
            DelTXSX: function (scel) {

                if (confirm("确定要删除么？")) {
                    $.post("/API/FTAPI.ashx", { Action: "DELTXSX", P1: scel.ID }, function (result) {
                        var jsonresult = $.parseJSON(result)
                        if ($.trim(jsonresult.ErrorMsg) != "") {
                            ComFunJS.winwarning(jsonresult.ErrorMsg);
                        } else {
                            model.CommonData.remove(scel);
                        }
                    })
                }
            },
            LB: function () {
                model.Type = $(this).attr("vl");
                if ($(this).hasClass("btn-primary")) {
                    model.GetTXData();
                }
                else {
                    $(".leibie").removeClass("btn-primary");
                    $(".leibie").addClass("btn-white");
                    $(this).removeClass("btn-white");
                    $(this).addClass("btn-primary");
                    model.GetTXData();
                }
            },
            IsShowTR: false,
            getMenu: function () {
                var setting = {
                    data: {
                        simpleData: {
                            enable: true,
                            idKey: "id",
                            pIdKey: "pId",
                            rootPId: 0
                        }
                    },
                    view: {
                        showLine: false
                    },
                    callback: {
                        onClick: model.zTreeOnClick
                    }
                };
                $.ajax({
                    type: "GET",
                    url: "/API/SZHLAPI.ashx",
                    dataType: "html",
                    data: { "Action": "GETALLBMUSERLIST" },
                    success: function (msg) {
                        if (JSON.parse(msg).Result) {
                            model.IsShowTR = true;
                        }
                        zTreeObj = $.fn.zTree.init($("#tree"), setting, eval(JSON.parse(msg).Result));
                    }
                });
            },
            zTreeOnClick: function (event, treeId, treeNode) {
                model.queryuser = "";
                model.CommonData.clear();
                if (treeNode.isUser) {
                    model.queryuser = treeNode.id;
                } else {
                    model.menutype = treeNode.id;
                    if (treeNode.children.length > 0 && treeNode.children[0].isUser) {

                        $(treeNode.children).each(function (i, user) {
                            model.queryuser += user.id + ",";
                        })
                        model.queryuser = model.queryuser.substring(0, model.queryuser.length - 1);
                    }
                }
                model.GetTXData();
            }

        });
        avalon.ready(function () {
            ComFunJS.initsetajax();
            model.GetTXData();
            model.getMenu();
        })

    </script>
</head>
<body class="gray-bg" ms-controller="TXSX">

    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-3">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <div class="file-manager">
                            <div class="clearfix"></div>
                             <h4 class="tag-title"><a href="APP_CQQD.html">我的考勤</a></h4>
                            <h4 class="tag-title" ms-if="model.IsShowTR">他人考勤</h4>
                            <ul id="tree" ms-if="model.IsShowTR" class="ztree"></ul>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-9">
                <div class="ibox">
                    <div class="box" style="margin-bottom:15px;">

                        <h2>
                            考勤签到
                        </h2>
                        <div class="mail-tools tooltip-demo m-t-md">
                            <div class="btn-group pull-right">
                                <div id="pageDiv" class="text-center"></div>
                            </div>
                             <div class="input-group-btn stbtn">
                                   
                                  <button type="button" class="btn btn-sm btn-primary" ms-click="setshowtype('2')">
                                        日历
                                    </button>
                                  <button type="button" class="btn btn-sm btn-default" ms-click="setshowtype('1')">
                                        列表
                                    </button>
                                </div>

                            
                            <div class="clearfix"></div>
                        </div>

                    </div>

                </div>
                <div class="full-height-scroll">
                    <div class="table-responsive" ms-if="ShowType=='1'">
                        <table class="table  table-hover">
                            <thead>
                                <tr>
                                    <th>考勤时间</th>
                                    <th>姓名</th>
                                    <th>考勤状态</th>
                                   <!-- <th>操作</th>-->
                                </tr>
                            </thead>
                            <tbody>
                                <tr ms-repeat-el="CommonData">
                                    <td>
                                        {{el.CRDate|date("yyyy年MM月dd日 HH:mm")}}
                                    </td>
                                    <td>
                                        {{el.CRUserName}}
                                    </td>
                                    <td>{{el.CRType}}</td>

                                    <!--<td class="client-status">
                                        <a class=" btn btn-white btn-xs" ms-click="ViewDT(el.ID)"><i class="fa fa-search"></i> 查看 </a>
                                        <a class=" btn btn-primary btn-xs" ms-click="EditTXSX(el.ID)" ms-if="el.CRUser==username"><i class=" fa fa-pencil"></i> 编辑 </a>
                                        <a class="btn btn-danger btn-xs" ms-click="DelTXSX(el)" ms-if="el.CRUser==username"><i class="fa fa-trash-o"></i> 删除 </a>
                                    </td>-->
                                </tr>
                            </tbody>
                        </table>
                    </div>

                     <div id="calendar" ms-if="ShowType=='2'"></div>

                </div>
            </div>

        </div>
    </div>
</body>
</html>
